package pers.zxk.jlytnews.dao.impl;

import pers.zxk.jlytnews.dao.FeedbackDao;
import pers.zxk.jlytnews.util.DBconn;

import java.sql.SQLException;

public class FeedbackDaoImpl implements FeedbackDao {
    @Override
    public boolean addFeedback(String title, String contents, String contact, String date) throws SQLException, ClassNotFoundException {
        boolean flag = false;
        DBconn.init();
        int i = DBconn.addUpdDel("insert into tb_feedback (title,contents,contact,date) " +
                "values('" + title + "','" + contents + "','" + contact + "','" + date + "')");
        if (i > 0) {
            flag = true;
        }
        DBconn.closeConn();
        return flag;
    }

    @Override
    public boolean delFeedback(int id) throws SQLException, ClassNotFoundException {
        boolean flag = false;
        DBconn.init();
        String sql = "delete from tb_feedback where id=" + id;
        int i = DBconn.addUpdDel(sql);
        if (i > 0) {
            flag = true;
        }
        DBconn.closeConn();
        return flag;
    }
}
